layui.define(['laydate', 'jquery'], function (exports) {
    const {laydate, jquery: $} = layui;
    exports('date', {
        render: function (config) {
            config = $.extend(true, {
                type: "datetime",
                value: '',
                theme: getComputedStyle(document.documentElement)
                    .getPropertyValue('--biz-theme-color').trim()
            }, config);

            if(!config.value || config.value === 'undefined'){
                config.value = '';
            }else{
                config.value = new Date(parseInt(config.value) * 1000)
            }

            laydate.render({
                elem: config.elem, //指定元素
                type: config.type,
                value: config.value,
                theme: config.theme
            })
        }
    });
})